<%@page import="net.vinote.smart.platform.service.util.ResultCode"%>
<%@page import="net.vinote.smart.platform.service.SRE"%>
<%@page import="net.vinote.smart.platform.base.Platform"%>
<%@page import="net.vinote.smart.platform.service.GeneralTools"%>
<%@page import="net.vinote.smart.platform.comm.PlatformConst"%>
<%@page import="net.vinote.smart.platform.comm.StringFunction"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
	boolean isCookieLogin = SRE.getSystemParameter().getAutoLogin() == PlatformConst.Yes;
	boolean isVerify = SRE.getSystemParameter().getVerifyCode() == PlatformConst.Yes;
	if (isCookieLogin) {
		Cookie[] cookies = request.getCookies();
		if (cookies != null) {
	for (Cookie c : cookies) {
		request.setAttribute(c.getName(), c.getValue());
	}
	String userPwd = net.vinote.smart.platform.service.GeneralTools.decrypt(StringFunction
	.nullToBlank(request.getAttribute("u&p")));
	int index = -1;
	if (userPwd != null && (index = userPwd.indexOf(" ")) >= 0
	&& index < userPwd.length()) {
		request.setAttribute("userid",
		userPwd.substring(0, index));
		request.setAttribute("password",
		userPwd.substring(index + 1));
	}
		}
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%=SRE.getSystemParameter().getSystemName()%></title>
<link rel="shortcut icon" href="favicon.ico" />

<script type="text/javascript"
	src="<%=basePath%>comm/js/jquery-1.10.1.js"></script>
<%-- <script type="text/javascript" src="<%=basePath%>comm/js/core.js"></script>
<script type="text/javascript" src="<%=basePath%>comm/js/aes.js"></script>
<script type="text/javascript" src="<%=basePath%>comm/js/enc-base64.js"></script> --%>

<link href="<%=basePath%>comm/css/style.css" rel="stylesheet"
	type="text/css" />
<script>
$(function(){
	$('#message span').fadeOut(3000);
	$('input[name=userid]').focus();
	<%if(isVerify){%>
	$('#verify').attr('src','verify?'+new Date());
	<%}%>
<%if(isCookieLogin){%>
	//自动登录选中时,勾选记住密码
	$("#autoLogin").click(function(){
		if($(this).attr('checked')){
			$('#recodePwd').attr('checked','checked');
		}
	});
	//表单提交前为checkbox赋值
	$("form").submit(function(){
		$(':checkbox').val('0');
		$(':checkbox:checked').val('1');
		return true;
	});
	<%if(PlatformConst.YES.equals(request.getAttribute("autoLogin"))){%>
	$('#submit').click();
	<%}%>
<%}%>
});

function Encrypt(word){
	 var key = CryptoJS.enc.Utf8.parse("0102030405060708");	
	 var iv  = CryptoJS.enc.Utf8.parse('0102030405060708');	
	 var srcs = CryptoJS.enc.Utf8.parse(word);
	alert(CryptoJS.AES);
	 var encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv,mode:CryptoJS.mode.CBC});
	 $('#show').html(encrypted.toString());
    return encrypted.toString();
}
function Decrypt(word){
	 var key = CryptoJS.enc.Utf8.parse("0102030405060708");	
	 var iv  = CryptoJS.enc.Utf8.parse('0102030405060708');	
	 var decrypt = CryptoJS.AES.decrypt(srcs, key, { iv: iv,mode:CryptoJS.mode.CBC});
	 return CryptoJS.enc.Utf8.stringify(encrypted).toString();
}
</script>
</head>
<body>
	<!-- <button onclick="Encrypt('zjw')">Test</button> -->
	<div id="show"></div>
	<div id="outDiv">
		<div id="innerDiv">
			<div id="sysTitle">
				<div>
					<div class="edge left"></div>
					<div class="edge right"></div>
					<div class="center">
						<h3><%=SRE.getSystemParameter().getSystemName()%></h3>
					</div>
				</div>
			</div>
			<div id="message">
				<span><%=StringFunction.nullToBlank((String)(session.getAttribute(ResultCode.MESSAGE)))%>
					<%
		session.removeAttribute(ResultCode.MESSAGE);
	%></span>&nbsp;
			</div>
			<form action="login" method="post">
				<table cellpadding="0" cellspacing="4" border="0"
					style="margin: auto;">
					<tbody>
						<tr>
							<td><b>用户名:</b></td>
							<td><input type="text" name="userid"
								value="<%=StringFunction.nullToBlank(request.getAttribute("userid"))%>" /></td>
						</tr>
						<tr>
							<td><b>&nbsp;&nbsp;&nbsp;&nbsp;密码:</b></td>
							<td><input type="password" name="password"
								value="<%=StringFunction.nullToBlank(request.getAttribute("password"))%>" /></td>
						</tr>
						<%
					if(SRE.getSystemParameter().getVerifyCode()==1){
				%>
						<tr>
							<td><b>验证码:</b></td>
							<td valign="middle"><input type="text" name="verifyCode"
								style="width: 82px" />&nbsp; <img alt="验证码" src="verify"
								id='verify'
								style="border: 1px solid #d2d2d2; vertical-align: middle;">&nbsp;
								<a href="javascript:void(0);" id='reload'
								onclick="javascript:$('#verify').attr('src','verify?'+new Date());">看不清楚?</a></td>
						</tr>
						<%
					}
				%>
					</tbody>
					<%
				if(SRE.getSystemParameter().getAutoLogin()==PlatformConst.Yes) {
			%>
					<tfoot>
						<tr>
							<td colspan="2" align="center"><input type="checkbox"
								name="recodePwd" id="recodePwd"
								<%=PlatformConst.YES.equals(request.getAttribute("recodePwd"))?"checked='checked'":""%> /><label
								for="recodePwd">记住密码</label> <input type="checkbox"
								name="autoLogin" id="autoLogin"
								<%=PlatformConst.YES.equals(request.getAttribute("autoLogin"))?"checked='checked'":""%> /><label
								for="autoLogin">自动登录</label></td>
						</tr>
					</tfoot>
					<%
				}
			%>
				</table>
				<p style="text-align: right; margin-right: 30px">
					<button id="submit" type="submit">登录</button>
					<button id="reset" type="reset">重置</button>
				</p>
			</form>
			<div style="text-align: center;">
				<%
		if(PlatformConst.Yes==SRE.getSystemParameter().getOpenRegister()){
	%>
				<a href="userRegister.jsp">用户注册</a>
				<%}else{ %>
				zhengjunweimail@163.com
				<%} %>
			</div>
		</div>
	</div>
	<a href="upload.html">test</a>
</body>
</html>